package com.xbongbong.paas.enums;

import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.base.CommunicateBaseEnum;
import com.xbongbong.saas.enums.business.ClueEnum;
import com.xbongbong.saas.enums.base.CommunicateBaseEnum;
import com.xbongbong.saas.enums.business.CommunicatePlanEnum;
import com.xbongbong.saas.enums.business.CustomerCommunicateEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.InstockEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.enums.business.ProductionInstockEnum;
import com.xbongbong.saas.enums.business.PurchaseInstockEnum;
import com.xbongbong.saas.enums.business.RefundInstockEnum;
import com.xbongbong.saas.enums.business.ReturnedMaterielInstockEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import com.xbongbong.saas.enums.business.WarehouseEnum;
import com.xbongbong.saas.enums.business.WorkOrderEnum;
import com.xbongbong.saas.enums.business.WorkOrderOutstockEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 外链各业务不支持在新建页面展示的字段(前面已经根据类型处理过一波，这里是每个业务特殊的字段)
 *
 * @author 曹远远
 * @version v1.0
 * @date 2020/8/14 10:59
 * @since v1.0
 */
@Getter
public enum OuterLinkAddRemoveAttrEnum {
    // crm
    CUSTOMER(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), Arrays.asList(CustomerManagementEnum.PARENT_HIDE.getAttr(), CustomerManagementEnum.WASTAGE.getAttr(), CustomerManagementEnum.WASTAGE_MEMO.getAttr(), CustomerManagementEnum.BACK_PUBLIC_DATE.getAttr(), CustomerManagementEnum.IS_ARCHIVED.getAttr(), CustomerManagementEnum.CONTACT_NAME.getAttr(), CustomerManagementEnum.CONTACT_PHONE.getAttr(), CustomerManagementEnum.LAST_CONNECT_TIME.getAttr(), CustomerManagementEnum.SCORE.getAttr())),
    SALES_OPPORTUNITY(XbbRefTypeEnum.SALES_OPPORTUNITY.getCode() , Arrays.asList(SalesOpportunityEnum.WASTAGE.getAttr(), SalesOpportunityEnum.WASTAGE_MEMO.getAttr())),
    CUSTOMER_COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode(), Arrays.asList(CommunicateBaseEnum.COMMUNICATE_BUSINESS.getAttr(), CustomerCommunicateEnum.IF_REMIND.getAttr(), CustomerCommunicateEnum.NEXT_COMMUNICATE_TIME.getAttr(), CustomerCommunicateEnum.NOTIFY_TYPE.getAttr(), CustomerCommunicateEnum.NOTIFY_TIME.getAttr(), CustomerCommunicateEnum.NEXT_NOTIFY_MEMO.getAttr(), CustomerCommunicateEnum.ENTER_COMMUNICATE_PLAN.getAttr())),
    SUPPLIER_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), Arrays.asList(CommunicateBaseEnum.COMMUNICATE_BUSINESS.getAttr())),
    CLUE(XbbRefTypeEnum.CLUE.getCode(), Arrays.asList(ClueEnum.SCORE.getAttr())),
    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), Arrays.asList(CommunicatePlanEnum.EXECUTOR.getAttr(), CommunicatePlanEnum.NOTIFY_TYPE.getAttr(), CommunicatePlanEnum.NOTIFY_TIME.getAttr())),
    // 进销存,
    // 产品分类 规格 仓库 供应商
    PRODUCT(XbbRefTypeEnum.PRODUCT.getCode() , Arrays.asList(
            ProductEnum.CATEGORY_ID.getAttr(),
            ProductEnum.WAREHOUSE.getAttr(),
            ProductEnum.WAREHOUSE_INFO.getAttr(),
            ProductEnum.WAREHOUSE_LINK_TEXT.getAttr(),
            ProductEnum.STOCK_NOTIFY.getAttr(),
            ProductEnum.IS_NOTIFY.getAttr(),
            ProductEnum.STOCK_INFO.getAttr(),
            ProductEnum.ASSOCIATED_INFO.getAttr(),
            ProductEnum.BATCH_SHELF_LIFE_MANAGEMENT.getAttr(),
            ProductEnum.ENABLE_BATCH_SHELF_LIFE.getAttr(),
            ProductEnum.SHELF_LIFE_DAYS.getAttr(),
            ProductEnum.EXPIRATION_ALERT_DAYS.getAttr(),
            ProductEnum.SERIAL_NUMBER_MANAGEMENT.getAttr(),
            ProductEnum.ENABLE_SERIAL_NUMBER.getAttr(),
            ProductEnum.SUPPLIER.getAttr())),
    // 采购入库单
    PURCHASE_INSTOCK(XbbRefTypeEnum.PURCHASE_INSTOCK.getCode(), Arrays.asList(
            PurchaseInstockEnum.REF_ID.getAttr(),
            PurchaseInstockEnum.PRODUCT.getAttr(),
            PurchaseInstockEnum.SUPPLIER_ID.getAttr(),
            PurchaseInstockEnum.WAREHOUSE_ID.getAttr())),
    // 销售退货入库单
    REFUND_INSTOCK(XbbRefTypeEnum.REFUND_INSTOCK.getCode(), Arrays.asList(
            RefundInstockEnum.CUSTOMER_ID.getAttr(),
            RefundInstockEnum.REF_ID.getAttr(),
            RefundInstockEnum.WAREHOUSE_ID.getAttr(),
            RefundInstockEnum.PRODUCT.getAttr())),
    // 其他入库单
    OTHER_INSTOCK(XbbRefTypeEnum.OTHER_INSTOCK.getCode(), Arrays.asList(
            InstockEnum.REF_ID.getAttr(),
            InstockEnum.PRODUCT.getAttr(),
            InstockEnum.WAREHOUSE_ID.getAttr())),
    // 生产入库单
    PRODUCTION_INSTOCK(XbbRefTypeEnum.PRODUCTION_INSTOCK.getCode(), Arrays.asList(
            ProductionInstockEnum.REF_ID.getAttr(),
            ProductionInstockEnum.WAREHOUSE_ID.getAttr(),
            ProductionInstockEnum.PRODUCT.getAttr())),
    // 生产退料单
    RETURNED_MATERIEL_INSTOCK(XbbRefTypeEnum.RETURNED_MATERIEL_INSTOCK.getCode(), Arrays.asList(
            ReturnedMaterielInstockEnum.REF_ID.getAttr(),
            ReturnedMaterielInstockEnum.WAREHOUSE_ID.getAttr(),
            ReturnedMaterielInstockEnum.PRODUCT.getAttr())),

//    OUTSTOCK(XbbRefTypeEnum.OUTSTOCK.getCode(), "enum.redundantTemplateType.name.outstock", XbbRefTypeEnum.OUTSTOCK.getAlias()),
//    CONTRACT_OUTSTOCK(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getName(), XbbRefTypeEnum.CONTRACT_OUTSTOCK.getAlias()),
//    RETURNED_PURCHASE_OUTSTOCK(XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getCode(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getName(), XbbRefTypeEnum.RETURNED_PURCHASE_OUTSTOCK.getAlias()),
//    PRODUCTION_MATERIEL_OUTSTOCK(XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getCode(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getName(), XbbRefTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK.getAlias()),
//    OTHER_OUTSTOCK(XbbRefTypeEnum.OTHER_OUTSTOCK.getCode(), XbbRefTypeEnum.OTHER_OUTSTOCK.getName(), XbbRefTypeEnum.OTHER_OUTSTOCK.getAlias()),
    //
      WORK_ORDER_OUTSTOCK(XbbRefTypeEnum.WORK_ORDER_OUTSTOCK.getCode(),Arrays.asList(
        WorkOrderOutstockEnum.LINK_CONTACT.getAttr())),
//    INSTOCK(XbbRefTypeEnum.INSTOCK.getCode(), "enum.redundantTemplateType.name.instock", XbbRefTypeEnum.INSTOCK.getAlias())

    //
//    TRANSFER(XbbRefTypeEnum.TRANSFER.getCode(), "enum.redundantTemplateType.name.transfer", XbbRefTypeEnum.TRANSFER.getAlias()),
//    INVENTORY(XbbRefTypeEnum.INVENTORY.getCode(), "enum.redundantTemplateType.name.inventory", XbbRefTypeEnum.INVENTORY.getAlias()),
//    SUPPLIER(XbbRefTypeEnum.SUPPLIER.getCode(), "enum.redundantTemplateType.name.supplier", XbbRefTypeEnum.SUPPLIER.getAlias()),
//    SUPPLIER_CONTACT(XbbRefTypeEnum.SUPPLIER_CONTACT.getCode(), "enum.redundantTemplateType.name.supplier_contact", XbbRefTypeEnum.SUPPLIER_CONTACT.getAlias()),
//    JXC_COMMUNICATE(XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getCode(), "enum.redundantTemplateType.name.jxc_communicate", XbbRefTypeEnum.SUPPLIER_COMMUNICATE.getAlias()),
      WAREHOUSE(XbbRefTypeEnum.WAREHOUSE.getCode(), Arrays.asList(
              WarehouseEnum.MANAGER_DEP_ID.getAttr())),
//    ASSEMBLE(XbbRefTypeEnum.ASSEMBLE.getCode(), "enum.redundantTemplateType.name.assemble", XbbRefTypeEnum.ASSEMBLE.getAlias()),
//    BOMBILL(XbbRefTypeEnum.BOM_BILL.getCode(), XbbRefTypeEnum.BOM_BILL.getName(), XbbRefTypeEnum.BOM_BILL.getAlias()),
//    PRODUCTIONORDER(XbbRefTypeEnum.PRODUCTION_ORDER.getCode(), XbbRefTypeEnum.PRODUCTION_ORDER.getName(), XbbRefTypeEnum.PRODUCTION_ORDER.getAlias()),
//    SIMULATED_PRODUCTION(XbbRefTypeEnum.SIMULATED_PRODUCTION.getCode(), XbbRefTypeEnum.SIMULATED_PRODUCTION.getName(), XbbRefTypeEnum.SIMULATED_PRODUCTION.getAlias()),
//    STOCK_SEARCH(XbbRefTypeEnum.STOCK_SEARCH.getCode(), XbbRefTypeEnum.STOCK_SEARCH.getName(), XbbRefTypeEnum.STOCK_SEARCH.getAlias()),
//    WARNING_SEARCH(XbbRefTypeEnum.WARNING_SEARCH.getCode(), XbbRefTypeEnum.WARNING_SEARCH.getName(), XbbRefTypeEnum.WARNING_SEARCH.getAlias()),
//    GUARANTEE_SEARCH(XbbRefTypeEnum.GUARANTEE_SEARCH.getCode(), XbbRefTypeEnum.GUARANTEE_SEARCH.getName(), XbbRefTypeEnum.GUARANTEE_SEARCH.getAlias()),
//    CALL_LOG(XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getCode() , XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getName(), XbbRefTypeEnum.CALL_CENTER_CALL_LOG.getAlias()),
//    QUOTATION(XbbRefTypeEnum.QUOTATION.getCode(), XbbRefTypeEnum.QUOTATION.getName(), XbbRefTypeEnum.QUOTATION.getAlias()),
//    ORI_STOCK(XbbRefTypeEnum.ORI_STOCK.getCode(), XbbRefTypeEnum.ORI_STOCK.getName(), XbbRefTypeEnum.ORI_STOCK.getAlias()),
//    REIMBURSEMENT_FORM(XbbRefTypeEnum.REIMBURSEMENT_FORM.getCode(), XbbRefTypeEnum.REIMBURSEMENT_FORM.getName(), XbbRefTypeEnum.REIMBURSEMENT_FORM.getAlias()),
//    EXPENSE(XbbRefTypeEnum.EXPENSE.getCode(), XbbRefTypeEnum.EXPENSE.getName(), XbbRefTypeEnum.EXPENSE.getAlias()),
//    STOCK_FLOW_BILL(XbbRefTypeEnum.STOCK_FLOW_BILL.getCode(), XbbRefTypeEnum.STOCK_FLOW_BILL.getName(), XbbRefTypeEnum.STOCK_FLOW_BILL.getAlias()),
//    STOCK_STANDING_BOOK(XbbRefTypeEnum.STOCK_STANDING_BOOK.getCode(), XbbRefTypeEnum.STOCK_STANDING_BOOK.getName(), XbbRefTypeEnum.STOCK_STANDING_BOOK.getAlias()),


    // 资金

//    COMMUNICATE(XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getCode() , "enum.redundantTemplateType.name.communicate", XbbRefTypeEnum.CUSTOMER_COMMUNICATE.getAlias()),
//    COMMUNICATE_PLAN(XbbRefTypeEnum.COMMUNICATE_PLAN.getCode(), XbbRefTypeEnum.COMMUNICATE_PLAN.getName(), XbbRefTypeEnum.COMMUNICATE_PLAN.getAlias()),
//    //	SALESTAGEFEEDBACK(7,"销售阶段反馈", "salesStageFeedback"),
//    WORKREPORT(XbbRefTypeEnum.WORK_REPORT.getCode(),"enum.redundantTemplateType.name.workreport",XbbRefTypeEnum.WORK_REPORT.getAlias()),
//    WORKREPORT_DAILY(XbbRefTypeEnum.WORKREPORT_DAILY.getCode(), "enum.redundantTemplateType.name.workreport_daily", XbbRefTypeEnum.WORKREPORT_DAILY.getAlias()),
//    WORKREPORT_WEEKLY(XbbRefTypeEnum.WORKREPORT_WEEKLY.getCode(), "enum.redundantTemplateType.name.workreport_weekly",XbbRefTypeEnum.WORKREPORT_WEEKLY.getAlias()),
//    WORKREPORT_MONTHLY(XbbRefTypeEnum.WORKREPORT_MONTHLY.getCode(), "enum.redundantTemplateType.name.workreport_monthly", XbbRefTypeEnum.WORKREPORT_MONTHLY.getAlias()),
//    PAYMENT_SHEET(XbbRefTypeEnum.PAYMENT_SHEET.getCode(), "enum.redundantTemplateType.name.payment_sheet", XbbRefTypeEnum.PAYMENT_SHEET.getAlias()),
//    PAYMENT(XbbRefTypeEnum.PAYMENT.getCode(),"enum.redundantTemplateType.name.payment", XbbRefTypeEnum.PAYMENT.getAlias()),
//    PAY_PLAN(XbbRefTypeEnum.PAY_PLAN.getCode(),"enum.redundantTemplateType.name.pay_plan",XbbRefTypeEnum.PAY_PLAN.getAlias()),
//    PAY_SHEET(XbbRefTypeEnum.PAY_SHEET.getCode(), "enum.redundantTemplateType.name.pay_sheet", XbbRefTypeEnum.PAY_SHEET.getAlias()),
//    INVOICE(XbbRefTypeEnum.INVOICE.getCode(),"enum.redundantTemplateType.name.invoice", XbbRefTypeEnum.INVOICE.getAlias()),
//    PURCHASE_INVOICE(XbbRefTypeEnum.PURCHASE_INVOICE.getCode(),"enum.redundantTemplateType.name.purchase_invoice", XbbRefTypeEnum.PURCHASE_INVOICE.getAlias()),
//    REFUND(XbbRefTypeEnum.REFUND.getCode(),"enum.redundantTemplateType.name.refund", XbbRefTypeEnum.REFUND.getAlias()),
//    STOCK_PRODUCT(XbbRefTypeEnum.STOCK_PRODUCT.getCode(), "enum.redundantTemplateType.name.stock_product", XbbRefTypeEnum.STOCK_PRODUCT.getAlias()),
    // 工单
      WORKORDER(XbbRefTypeEnum.WORK_ORDER.getCode(),Arrays.asList(
        WorkOrderEnum.LINK_CUSTOMER.getAttr(),
        WorkOrderEnum.LINK_CONTACT.getAttr(),
        WorkOrderEnum.LINK_OPPORTUNITY.getAttr(),
        WorkOrderEnum.LINK_CONTRACT.getAttr(),
        WorkOrderEnum.SPARE_PARTS.getAttr())),
//    //	PRICE_COMPARE(100,"比价单", "priceCompare"),
//    PURCHASE(XbbRefTypeEnum.PURCHASE.getCode(), "enum.redundantTemplateType.name.purchase", XbbRefTypeEnum.PURCHASE.getAlias()),
//    RETURNED_PURCHASE(XbbRefTypeEnum.RETURNED_PURCHASE.getCode(), "enum.redundantTemplateType.name.returned_purchase", XbbRefTypeEnum.RETURNED_PURCHASE.getAlias()),

    ;

    /**
     * 业务类型
     */
    private Integer businessType;
    /**
     * 不支持的字段
     */
    private List<String> fieldAttrs;



    OuterLinkAddRemoveAttrEnum(Integer businessType, List<String> fieldAttrs) {
        this.businessType = businessType;
        this.fieldAttrs = fieldAttrs;
    }

    public static List<String> getAttrList(Integer type) {
        for (OuterLinkAddRemoveAttrEnum e : values()) {
            if (Objects.equals(type, e.getBusinessType())) {
                return e.getFieldAttrs();
            }
        }
        return new ArrayList<>();
    }


}
